package com.haikesi.api.syslog.controller;

import com.github.pagehelper.PageInfo;
import com.haikesi.api.base.ApiIndex;
import com.haikesi.api.base.R;
import com.haikesi.api.base.annotation.Token;
import com.haikesi.api.syslog.domain.vo.SysLogSaveVO;
import com.haikesi.api.syslog.domain.vo.SysLogSearchVO;
import com.haikesi.api.syslog.domain.vo.SysLogVO;
import com.haikesi.api.syslog.service.ISysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName SysLogController
 * @Author HandsomeBugs
 * @Date 2019/4/25 14:01
 * @Version 1.0
 **/

@Api(description = "系统日志相关接口", tags = ApiIndex.SysLogController)
@RequestMapping(value = "/api/sysLog")
@RestController
public class SysLogController {
    @Autowired
    private ISysLogService sysLogService;

    @ApiOperation(value = "查询列表")
    @GetMapping(value = "/list")
    @ApiImplicitParam(name = "token", value = "签名", paramType = "query", dataType = "String")
    @Token
    public R<PageInfo<List<SysLogVO>>> list(
            @ApiParam(value = "查询参数") @ModelAttribute SysLogSearchVO searchVO) {
        List<SysLogVO> list = sysLogService.getList(searchVO);
        PageInfo pageInfo = new PageInfo(list);
        return new R(pageInfo);
    }


    @ApiOperation(value = "创建系统日志",hidden = true)
    @PostMapping(value = "")
    //    @ApiImplicitParam(name = "token", value = "签名", paramType = "query", dataType = "String")
    //    @Token
    public R create(
            @ApiParam(value = "添加参数") @Valid @RequestBody SysLogSaveVO saveVO) {
        sysLogService.create(saveVO);
        return new R();
    }
}
